// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import "babel-polyfill";
// import fastclick from 'fastclick';
import Vue from "vue";
// import Vant from 'vant';
import {
    Lazyload,
    NoticeBar,
    Swipe,
    SwipeItem,
    CountDown,
    DatetimePicker,
    Popup
} from "vant";

import "vant/lib/index.css";

// import 'common/weui/weui.less';

import "common/scss/index.scss";
import $alert from "base/alert/index";
import $toast from "base/toast/index";
import MyBread from "base/myBread/myBread";
import $confirm from "base/confirm/index";
import loading from "base/loading/index";
import $helpInfo from "base/helpInfo/index";
import $picker from "base/picker/index";
import Axios from "common/js/axios";
import ModalHelper from "common/js/moveTouch";
import subConfirm from "base/subConfirm/subConfirm";
import userLogin from "base/userLogin/index";

import App from "./App";
import store from "./store";
import router from "./router";

import Calendar from "vue-mobile-calendar";

// import Vconsole from 'vconsole';
// const vConsole = new Vconsole();
// Vue.use(vConsole)

// fastclick.attach(document.body);
Vue.config.productionTip = false;

// base component
Vue.prototype.$alert = $alert;
Vue.prototype.$toast = $toast;
Vue.prototype.$confirm = $confirm;
Vue.prototype.$helpInfo = $helpInfo;
Vue.prototype.$http = Axios;
Vue.prototype.$picker = $picker;
Vue.prototype.$modalHelper = ModalHelper;
// Vue.prototype.$subConfirm = subConfirm;
Vue.prototype.$userLogin = userLogin;
Vue.use(loading);
Vue.use(Calendar);
Vue.use(NoticeBar);
Vue.use(Popup);
Vue.use(Lazyload, {
    lazyComponent: true
});

Vue.use(Swipe);
Vue.use(CountDown);
Vue.use(SwipeItem);
Vue.use(DatetimePicker);

// 全局自定义组件
Vue.component(MyBread.name, MyBread);
Vue.component(subConfirm.name, subConfirm);
/* eslint-disable no-new */
new Vue({
    el: "#app",
    router,
    store,
    render: h => h(App),
    mounted() {
        // for ios
        document.body.addEventListener("touchstart", () => {});
    }
});
/**
 * 路由配置实现：document.title 由路由meta来决定
 * 帮助按钮设置，路由不为首页，bar显示
 */
router.afterEach(to => {
    // 跳转完成之后，修改document.title
    document.title = to.meta.title;
    // 默认帮助按钮不显示，需要显示在路由组件单独设置
    store.commit("SET_VISIBLE_HELP", false);
    // 首页不显示 bar
    if (to.name === "home") {
        store.commit("SET_VISIBLE_ALL", false);
    } else {
        store.commit("SET_VISIBLE_ALL", true);
    }
});
